Conversation
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.29.0 to 0.31.0. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/golang/crypto/commit/b4f1988a35dee11ec3e05d6bf3e90b695fbd8909"><code>b4f1988</code></a> ssh: make the public key cache a 1-entry FIFO cache</li> <li><a href="https://github.com/golang/crypto/commit/7042ebcbe097f305ba3a93f9a22b4befa4b83d29"><code>7042ebc</code></a> openpgp/clearsign: just use rand.Reader in tests</li> <li><a href="https://github.com/golang/crypto/commit/3e90321ac7bcee3d924ed63ed3ad97be2079cb56"><code>3e90321</code></a> go.mod: update golang.org/x dependencies</li> <li><a href="https://github.com/golang/crypto/commit/8c4e668694ccbaa1be4785da7e7a40f2ef93152b"><code>8c4e668</code></a> x509roots/fallback: update bundle</li> <li>See full diff in <a href="https://github.com/golang/crypto/compare/v0.29.0...v0.31.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/hypermodeinc/modusDB/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR adds the initial issue and PR templates, a changelog, code of conduct, contributing guide, and security reporting instructions. We can enhance these over time.
**Description** Initialize Trunk for broader linting and security monitoring. Fix addressable issues. **Checklist** - [x] Code compiles correctly and linting passes locally
**Description** add readme to repo
<!-- markdownlint-disable first-line-heading -->
**Description**
Adds copyrights to all go files
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
staged and linked here
Thank you for your contribution to modusDB!
**Description** Move GitHub Actions workflows to Warp runners for faster tests through larger machine access. **Checklist** - [X] Code compiles correctly and linting passes locally
<!-- markdownlint-disable first-line-heading -->
**Description**
This PR adds support for reverse edges via the readFrom json tag
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
staged and linked here
**Description**
refactoring packages for clearer code, remove duplications, etc
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [ ] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
staged and linked here
**Description** more refactoring to simplify code in main modusdb package **Checklist** - [x] Code compiles correctly and linting passes locally
mangalaman93
left a comment
There was a problem hiding this comment.
I also do not understand the package structure having two levels of hierarchy with just one file in each package. This does not feel useful to me. packages are for dividing code for logically structuring it. I don't see that here.
This is a 10000 feet view of the PR. I will do another pass once some of these comments are addressed. This is a very long PR to review.
| "github.com/hypermodeinc/modusdb/api/utils" | ||
| ) | ||
|
|
||
| func HandleReverseEdge(jsonName string, value reflect.Type, nsId uint64, sch *schema.ParsedSchema, |
There was a problem hiding this comment.
we should move these to internal package if we want to have this package structure.
| return fmt.Sprintf(ObjQuery, qf(), extraFields) | ||
| } | ||
|
|
||
| func FormatObjsQuery(typeName string, qf QueryFunc, paginationAndSorting string, extraFields string) string { |
There was a problem hiding this comment.
what is the benefit of passing a function qf instead of passing the return value here?
There was a problem hiding this comment.
formatObjsQuery doesn't need queryfunc, its there to maintain code readability bc formatObjQuery does need it. it makes more sense if they both follow using qf
api_mutation_helpers.go
Outdated
| return gid, nil | ||
| } | ||
|
|
||
| func applyDqlMutations(ctx context.Context, db *DB, dms []*dql.Mutation) error { |
There was a problem hiding this comment.
All the functions that do mutations and query or alter or any other Dgraph operation, that should use moduDB APIs or equivalent so that we can make changes to it easily.
**Description**
On query of a type with a reverse edge, it modifies the type to remove
all other predicates. The expected logic should only alter the schema if
the type and predicate for the reverse edge does not exist.
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
staged and linked here
| **Is your feature request related to a problem? Please describe.** A clear and concise description | ||
| of what the problem is. Ex. I'm always frustrated when [...] | ||
|
|
||
| **Describe the solution you'd like** A clear and concise description of what you want to happen. | ||
|
|
||
| **Describe alternatives you've considered** A clear and concise description of any alternative | ||
| solutions or features you've considered. | ||
|
|
||
| **Additional context** Add any other context or screenshots about the feature request here. |
There was a problem hiding this comment.
Trunk merged the title and body of these paragraphs, because they were just bold text rather than headings. Use ## headings instead.
There was a problem hiding this comment.
Consider adding a section about Trunk. Feel free to copy from the one I did in Modus.
There was a problem hiding this comment.
This looks like it was copied from the Modus repo, but I've recently changed the text there. Please consider updating to match. (At minimum, update the headings to use ## markdown.)
There was a problem hiding this comment.
Since this is in trunk's configs dir, you'll be fighting against VS Code expecting it in the root. Trunk will have this config, and VS Code will have the default config.
You can fix that by adding the following to .vscode/settings.json
"markdownlint.config": {
"extends": ".trunk/configs/.markdownlint.json"
},There was a problem hiding this comment.
@mattjohnsonpint is this true even if you don't install markdownlint in the editor? Trunk takes care of running it, so I don't think it's needed as a VS Code extension
CHANGELOG.md
Outdated
| - feat: add readfrom json tag to support reverse edges | ||
| [#49](https://github.com/hypermodeinc/modusDB/pull/49) | ||
|
|
||
| - chore: Refactoring package management #51 [#51](https://github.com/hypermodeinc/modusDB/pull/51) |
There was a problem hiding this comment.
| - chore: Refactoring package management #51 [#51](https://github.com/hypermodeinc/modusDB/pull/51) | |
| - chore: Refactoring package management [#51](https://github.com/hypermodeinc/modusDB/pull/51) |
|
|
||
| If in doubt or contemplating a larger change, join the | ||
| [Hypermode Discord](https://discord.hypermode.com) and start a discussion in the | ||
| [#modus](https://discord.com/channels/1267579648657850441/1292948253796466730) channel. |
There was a problem hiding this comment.
| [#modus](https://discord.com/channels/1267579648657850441/1292948253796466730) channel. | |
| [#modusdb](https://discord.com/channels/1267579648657850441/1324490523725135872) channel. |
README.md
Outdated
| } | ||
|
|
||
| func main() { | ||
| db, err := New(NewDefaultConfig("/tmp/modusdb")) |
There was a problem hiding this comment.
| db, err := New(NewDefaultConfig("/tmp/modusdb")) | |
| cfg := modusdb.NewDefaultConfig("/tmp/modusdb") | |
| db, err := modusdb.New(cfg) |
README.md
Outdated
| } | ||
| fmt.Println(user) | ||
|
|
||
| _, queriedUser, err := modusdb.Get[User](db, gid) |
There was a problem hiding this comment.
It's unclear what the _ return value is. If it's the gid, why does the API accept a gid and also return one? Could they differ somehow?
| "github.com/hypermodeinc/modusdb/api/apiutils" | ||
| "github.com/hypermodeinc/modusdb/api/structreflect" | ||
| ) | ||
|
|
There was a problem hiding this comment.
Please add usage comments for at least these primary public functions. Otherwise, it's difficult to tell what the parameters and return values are supposed to be. Thanks.
There was a problem hiding this comment.
These tests take too long. Please separate this and other long-running integration tests using build tags. Thanks.
api.go
Outdated
| if len(ns) > 1 { | ||
| return nil, nil, fmt.Errorf("only one namespace is allowed") | ||
| } | ||
| ctx, n, err := getDefaultNamespace(db, ns...) |
There was a problem hiding this comment.
Here and in the rest of the API methods, we are creating the ctx context object ourselves inside the getDefaultNamespace function. Instead, we should be allowing the user to pass context in as a parameter (usually the first parameter).
For example, say the user wants the query to timeout if it takes to long to run. The normal way would be to use context.WithTimeout and pass that context in to the query function. But we've not given them any way to do that.
There was a problem hiding this comment.
... Also, it's unclear why there is Query as a global function that doesn't take a context but takes a db and a namespace, and db.Query which does take a context, but not a namespace.
IMHO, There should just be one way to query, not two.
db.go
Outdated
| return db.defaultNamespace.Mutate(ctx, ms) | ||
| } | ||
|
|
||
| func (db *DB) Load(ctx context.Context, schemaPath, dataPath string) error { |
There was a problem hiding this comment.
Let's just make this one LoadSchema(ctx, schemaPath), since we already have LoadData that does the same thing with dataPath.
| func (db *DB) Load(ctx context.Context, schemaPath, dataPath string) error { | |
| func (db *DB) Load(ctx context.Context, schemaPath, dataPath string) error { |
db.go
Outdated
| func (db *DB) DropData(ctx context.Context) error { | ||
| return db.gxy.DropData(ctx) | ||
| return db.defaultNamespace.DropData(ctx) | ||
| } | ||
|
|
||
| func (db *DB) AlterSchema(ctx context.Context, sch string) error { | ||
| return db.gxy.AlterSchema(ctx, sch) | ||
| return db.defaultNamespace.AlterSchema(ctx, sch) | ||
| } | ||
|
|
||
| func (db *DB) Query(ctx context.Context, q string) (*api.Response, error) { | ||
| return db.gxy.Query(ctx, q) | ||
| return db.defaultNamespace.Query(ctx, q) | ||
| } | ||
|
|
||
| func (db *DB) Mutate(ctx context.Context, ms []*api.Mutation) (map[string]uint64, error) { | ||
| return db.gxy.Mutate(ctx, ms) | ||
| return db.defaultNamespace.Mutate(ctx, ms) | ||
| } |
There was a problem hiding this comment.
Since these are the "escape hatches" - they shouldn't be primary methods on the db object. Let's put them elsewhere, such as db.advanced.QueryDQL etc... (maybe a different name, but under some object)
api.go
Outdated
| db.mutex.Lock() | ||
| defer db.mutex.Unlock() |
There was a problem hiding this comment.
I think this should be RLock and RUnlock
api.go
Outdated
| "github.com/hypermodeinc/modusdb/api/structreflect" | ||
| ) | ||
|
|
||
| func Create[T any](db *DB, object T, ns ...uint64) (uint64, T, error) { |
There was a problem hiding this comment.
This pattern will become a problem as we may need other options in the future. I suggest this use the functional options pattern instead, ie, WithNamespace(uint64) - which is more idiomatic for Go anyway.
api.go
Outdated
| return 0, object, err | ||
| } | ||
|
|
||
| return getByGid[T](ctx, n, gid) |
There was a problem hiding this comment.
I'm so/so on whether these create/upsert functions should always do a get at the end. The user could just do that themselves. And in the case of multiple inserts, they may just throw away the result so it's extraneous work that affects insert perf.
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package structreflect |
There was a problem hiding this comment.
This package and others we don't want the user calling should be nested under an internal package
**Description**
This PR updates the nomenclature from db and namespace to engine and
namespace to better represent common DB terminology
it also removes the notion of opertaion on both the entities, all
mutations, queries, and drop datas are conducted on namespaces. the
engine is responsibile for drop all & maintaining namespaces & state
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
staged and linked here
**Description** separate load and unit tests for faster workflow checks
This tells Trunk to ignore this issue raised by osv-scanner. Details of the issue are here: GHSA-9w9f-6mg8-jp7w It's safe to ignore the issue, as we do not consume the `bleve/http` pacakge.
**Description**
Please explain the changes you made here.
**Checklist**
- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
staged and linked here
No description provided.